<#include "include/_meta.html">
<!DOCTYPE HTML>
<html>
<head>
<title>维修记录表</title>

    <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
    <script src="vue/vue.min.js"></script>
</head>

<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 车辆管理 <span
            class="c-gray en">&gt;</span> 维修管理 <a class="btn btn-success radius r"
                                                  style="line-height:1.6em;margin-top:3px"
                                                  href="javascript:location.replace(location.href);" title="刷新"><i
                class="Hui-iconfont">&#xe68f;</i></a></nav>
<div  class="page-container">

    <div class="text-c">
        车牌号：<input type="text" class="input-text" style="width:250px" placeholder="请输入车牌号" id="carIdCard" name="carIdCard">

        经手人姓名：<input type="text" class="input-text" style="width:250px" placeholder="请输入经手人姓名" id="userName" name="userName">

        <button type="submit" class="btn btn-success" id="searchRepair" name=""><i class="Hui-iconfont">&#xe665;</i> 搜维修记录</button>
    </div>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" id="addRepair" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加维修记录</a>
        </span>

        <span class="r">
           共有数据：<strong id="pageTotal">54</strong> 条
        </span>
    </div>
    <table id="repairListTable" class="table table-border table-bordered table-bg table-hover ">
        <thead>
        <tr>
            <th scope="col" colspan="10" style="text-align: center">维修记录表</th>
        </tr>
        <tr class="text-c">
            <th>维修单号</th>
            <th>车牌号</th>
            <th>经手人姓名</th>
            <th>经手人电话</th>
            <th>维修地点</th>
            <th>维修费用</th>
            <th>维修内容</th>
            <th>维修开始时间</th>
            <th>维修结束时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="app">
        <tr  v-for="(item,index) in result" class="text-c">
            <td>{{item.repairId}}</td>
            <td>{{item.carIdCard}}</td>
            <td>{{item.user.userName}}</td>
            <td>{{item.user.phone}}</td>
            <td>{{item.repairPlace}}</td>
            <td>{{item.money}}</td>
            <td>{{item.repairContent}}</td>
            <td>{{item.repairStart}}</td>
            <td>{{item.repairEnd}}</td>
            <td>
                <a href="#" @click="editEvent(item.repairId)">编辑</a>
                <a href="#" @click="delEvent(item.repairId)">删除</a>
            </td>
        </tr>
        </tbody>
        <tr>
            <td colspan="10">
                <div id="pagenav"></div>
            </td>
        </tr>
    </table>
</div>

<#include "include/_footer.html">

<script type="text/javascript">

    var app = new Vue({
        el: '#repairListTable',
        data: {
            result: []
        }
    });

    var getRepairPageList = function (curr) {
        $.ajax({
            type: 'post',
            dataType: "json",
            url: "/getRepairList",
            data: {
                pageNum: curr || 1,
                pageSize: 5,
                userName: $("#userName").val(),
                carIdCard: $("#carIdCard").val(),
            },
            success: function (msg) {
                app.result = msg.repairList;
                $("#pageTotal").text(msg.count);
                laypage({
                    cont: "pagenav",
                    pages: msg.total,
                    skin: "#DB7023",
                    first: "第一页",
                    last: "最后一页",
                    curr: curr || 1,
                    jump: function (obj, first) {
                        if (!first) {
                            getRepairPageList(obj.curr);
                        }
                    }
                });
            }
        });
    }

    //初始化时立刻调用一次查询
    getRepairPageList();

    //单击搜索查询
    $("#searchRepair").click(function () {
        getRepairPageList();
    });

    //新增
    $("#addRepair").on("click",function () {
        layer.open({
            type:2,
            title:'增加维修记录',
            fix:false,
            maxmin:true,
            shadeClose:true,
            area:['1000px','600px'],
            content:'toAddRepair',
            end:function () {
                getRepairPageList();
            }
        })
    });

    //编辑
    var editEvent = function (id) {
        layer.open({
            type:2,
            title:'编辑用户',
            fix:false,
            maxmin:true,
            shadeClose:true,
            area:['1000px','600px'],
            content:'/toEditRepair?repairId='+id,
            end:function () {
                getRepairPageList();
            }
        })
    };

    //删除
    var delEvent = function (id) {
        layer.confirm("确定删除吗？",
            {btn:['是','否']},
            //是
            function(){
                $.ajax({
                    type:'POST',
                    dataType:'json',
                    url:'delRepair',
                    data:{
                        repairId:id
                    },
                    success:function (msg) {
                        getRepairPageList();
                        layer.msg("已经成功删除记录"+id,{icon:5});
                    }
                })
            },
            //否
            function () {

            }
        )
    }




</script>
</body>
</html>